<div id="treeDataStore" dojoType="dojo.data.ItemFileReadStore" url="content_menu.php" jsid="contentStore" /></div>
<div id="tree1" dojoType="dijit.Tree" store="contentStore" labelAttr="name" label="Menu">
	<script type="dojo/connect">
		
		var menu = dijit.byId("tree_menu");
		// when we right-click anywhere on the tree, make sure we open the menu
		menu.bindDomNode(this.domNode);


		dojo.connect(menu, "_openMyself", this, function(e){
		// get a hold of, and log out, the tree node that was the source of this open event
		try{
			var tn = dijit.getEnclosingWidget(e.target);
			//SET VARIABLES FOR USE IN RIGHT CLICK MENU FUNCTIONS
			contextStoryId = tn.item.storyid;
			contextItemTitle = tn.item.title;
		}catch(e){
			contextStoryId = null;
			contextItemTitle = null;
		}

		// now inspect the data store item that backs the tree node:
		//console.debug(tn.item.storyid);

		// contrived condition: if this tree node doesn't have any children, disable all of the menu items
		//menu.getChildren().forEach(function(i){ i.setDisabled(!tn.item.children); });



		
		if(String(contextStoryId).indexOf('CAT') != -1){
			//category item
			contOrCategory = 'category';
			setMenuOptions(1);
		}else if(String(contextStoryId).indexOf('CAT') == -1 && contextStoryId != null){
			//content item
			contOrCategory = 'content';
			setMenuOptions(0);
		}else{
			//root node (Menu)
			setMenuOptions(5);
		}


		});
		
	</script>
	<script type="dojo/method" event="onClick" args="item">
		try{
			if(contentStore.getValue(item, "storyid").indexOf('CAT') == -1){
				select_content(contentStore.getValue(item, "storyid"),XOOPS_URL);
			}
		}catch(err){
			//Handle errors here
		}
    </script>
 </div>